package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;


/*
 ID:	liluyan1
 LANG:	JAVA
 TASK:	crypt1
 */
public class crypt1 {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("crypt1.in"));
		int res = new crypt1().solve(f);
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"crypt1.out")));
		out.println(res);
		out.close();
		System.exit(0);
	}
	
	private int solve(BufferedReader f) throws IOException {
		int N = Integer.parseInt(f.readLine());
		int[] a = read(f, N);
		int count = 0;

		for (int i1=0; i1<N; i1++) {
			for (int i2=0; i2<N; i2++) {
				for (int i3=0; i3<N; i3++) {
					for (int i4=0; i4<N; i4++) {
						int p1 = a[i1] + a[i2]*10 + a[i3]*100;
						if (!satisfy(p1, a[i4], 3, a)) continue;
						
						for (int i5=0; i5<N; i5++) {
							if (satisfy(p1, a[i5], 3, a) && 
									satisfy(p1, a[i4]+a[i5]*10, 4, a))
								count++;
						}
					}
				}
			}
		}
		
		return count;
	}
	
	private boolean satisfy(int p1, int p2, int digits, int[] a) {
		String s = "" + p1*p2;
		if (s.length()!=digits) return false;
		for (char c : s.toCharArray()) {
			boolean exist = false;
			for (int i : a) {
				if (c == i + '0') {
					exist = true; break;
				}
			}
			if (!exist) return false;
		}
		return true;
	}
	
	private int[] read(BufferedReader f, int N) throws IOException {
		String[] t = f.readLine().split(" ");
		int[] a = new int[N];
		for (int i=0; i<N; i++) {
			a[i] = Integer.parseInt(t[i]);
		}
		return a;
	}
}
